var Page = function(){
    this.init();
};
Page.prototype = {
    params: {
        passport: '',
        businessId:''
    },
    init: function(){
        this.initParams();
        this.initEvent();
    },
    initParams: function(){
        this.params.passport = Pub.getCookie('_PASSPORT');
        this.params.businessId = Pub.getSession('businessId');
    },
    getData: function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            businessId:parseInt(_this.params.businessId),
        };
        console.log(paramsObj);
        Api.businesshelpdetails(paramsObj, function(data){
            console.log(data);
            $('#title').val(data.title);
            $('#describe').val(data.describe);
            $('#mobile').val(data.mobile);
            $('#address').val(data.address);
            $('#realName').val(data.realName);
            //$('#prepareTime').val(data.prepareTime);
            $('#userDeatil').click(function(event) {
               Pub.setSession('userId', data.userId);
               window.location.href = Pub.getHtmlUrl('./user-list-detail.html');
            });
            $('#reCont').val(data.replyContent);
            ue.ready(function() {//编辑器初始化完成再赋值
              ue.setContent(data.content);  //赋值给UEditor
            });



            // $('#classifySelect').val(data.classId);


        });
    },
    otherEvent:function(){
        var _this = this;
        $('.goods-checkbox input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        })
        $('#submit').click(function(event) {
            var content=$('#reCont').val();
            var paramsObj = {
                passport: _this.params.passport,
                businessId:parseInt(_this.params.businessId),
                replyContent:content
            };
            console.log(paramsObj);
            Api.businesshelpeditor(paramsObj, function(data){
                console.log(data);
                layui.use('layer', function(){
                    layer.msg('回复成功', {icon: 6});
                    setTimeout(function(){
                        window.location.href = Pub.getHtmlUrl('./business-assist-list.html');
                    },1500)
                });
            });
        });
    },
    initEvent: function(){
        var _this = this;
        _this.getData();
        _this.otherEvent();



    }
};
var page = new Page();